/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upn.sigemfi.rec.bc;

import edu.upn.sigemfi.rec.be.ComprobacionCliente;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author Diego
 */
public class ComprobacionClienteDelegate {

    private ProcesoCobranzaFacadeLocal local;

    public ComprobacionClienteDelegate() {
        local = (ProcesoCobranzaFacadeLocal) lookupComprobacionClienteFacade();
    }

    private ComprobacionClienteFacadeLocal lookupComprobacionClienteFacade() {
        try {
            Context c = new InitialContext();
            return (ComprobacionClienteFacadeLocal) c.lookup("java:comp/env/ComprobacionClienteFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }


    public List<ComprobacionCliente> listarComprobacionesPorCredito(long credito) throws Exception {
        try {
            return local.findAllComprobacionesPorCredito(credito);
        } catch (Exception e) {
            lookupComprobacionClienteFacade();
            throw new Exception("Listar Comprobaciones por Credito. " + e.getMessage(), e);
        }
    }
}
